#!/usr/bin/env/ python
# -*- coding: utf-8

"""
@project: python-file
@author: admin
@time: 2022/7/1
"""
import allure
from base.app.base import BasePage, BaseHandle
from selenium.webdriver.common.by import By


'''主页类'''
# 定义对象库层
class HomePage(BasePage):
	
	def __init__(self):
		super().__init__()
		# 菜单栏-服务
		self.service = By.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.ImageView"
		# 智联服务-小尼车间
		self.xncj = By.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/androidx.recyclerview.widget.RecyclerView[1]/android.widget.RelativeLayout[1]/android.widget.ImageView"
		
	# 定位菜单栏-服务
	def find_service(self):
		return self.get_element(self.service)
	
	# 定位智联服务-小尼车间
	def find_xncj(self):
		return self.get_element(self.xncj)
	
# 定义操作层
class HomeHandle(BaseHandle):
	
	def __init__(self):
		self.home_page = HomePage()
	
	@allure.step(title = "点击菜单栏-服务")
	def click_service(self):
		self.click_element(self.home_page.find_service())
		
	@allure.step(title = "点击智联服务-小尼车间")
	def click_xncj(self):
		self.click_element(self.home_page.find_xncj())
		
# 定义业务层
class HomeProxy:
	
	def __init__(self):
		self.home_handle = HomeHandle()
	
	def home(self):
		self.home_handle.click_service()    # 点击菜单栏-服务
		self.home_handle.click_xncj()   # 点击小尼车间